#coding=utf-8
#!/usr/bin/python
"""
信号


#     cd /d D:\python26 
#     python.exe D:\py\demo\sock_c.py

#       python.exe  .\dev_test\sock_c.py

"""
import os,sys,time
import wx

#信号处理
import signal


def signal_list():
    u" 所有信号"
    signals_names = {}
    for n in dir(signal):
        if n.startswith('SIG') and not n.startswith('SIG_'):
            signals_names[getattr(signal, n)] = n
    return signals_names
        


def signal_do(signum, frame):
    u" 信号处理 "
    print "signal is ",signum
    #print frame
    print "signal_do end"
    sys.exit()

#定义信号处理 函数
#signal.signal(信号,处理)






if __name__ == '__main__':  
    print signal_list()
    
   #win 没有 kill
    #kill() 可以发 SIGTERM  也是 Ctrl+c
    
    signal.signal(signal.SIGINT,signal_do)  #2
    signal.signal(signal.SIGTERM,signal_do)   # 15
 #   signal.signal(signal.SIGQUIT,signal_do)     #3
#    signal.signal(signal.SIGKILL,signal_do)    #9

    
    
    me_pid = os.getpid()
    print "signal is ",signal.SIGINT
    print "Process_Kill  pid is " ,os.getpid()
 
    #结束自己
    wx.Process_Kill(me_pid, wx.SIGINT)
    
    print "Process_Kill  pid is " ,os.getpid()
    #os.kill(me_pid,signal.SIGINT)  



    
    time.sleep(50)
    print __file__ ,':the end'
    sys.exit()
            